package com.briup.cms.service.impl;
import com.briup.cms.bean.RolePrivilege;
import com.briup.cms.bean.extend.RolePrivilegeExtend;
import com.briup.cms.dao.RolePrivilegeMapper;
import com.briup.cms.service.IRolePrivilegeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RolePrivilegeServiceImpl implements IRolePrivilegeService {
    @Resource
    private RolePrivilegeMapper rolePrivilegeMapper;

    @Override
    public List<RolePrivilege> findAll() {
        return rolePrivilegeMapper.selectAll();
    }

    @Override
    public void insertOrUpdate(RolePrivilege rolePrivilege) {
        if(rolePrivilege.getId()!=null){
            rolePrivilegeMapper.update(rolePrivilege);
        }else{
            rolePrivilegeMapper.insert(rolePrivilege);
        }
    }

    @Override
    public void deleteById(Long id) {
      rolePrivilegeMapper.deleteById(id);
    }

    @Override
    public List<RolePrivilegeExtend> findAllWithRole() {
        return rolePrivilegeMapper.selectAllWithRole();
    }
}
